package com.bocai.kelalacar.ui.car.main.ada;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bocai.kelalacar.R;
import com.bocai.kelalacar.base.BaseRecyclerAdapter;
import com.bocai.kelalacar.base.BaseRecyclerViewHolder;
import com.bocai.kelalacar.bean.MainListBean;
import com.bocai.kelalacar.util.DoubleUtil;
import com.bumptech.glide.Glide;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yuanfei on 2017/6/6.
 */

public class MainAdapter extends BaseRecyclerAdapter<MainListBean.OrderListBean> {


    @Override
    public void showData(BaseRecyclerViewHolder viewHolder, int i, List<MainListBean.OrderListBean> mItemDataList) {
        MyViewHolder myViewHolder = (MyViewHolder) viewHolder;
//        myViewHolder.tvAge.setText("车龄" + mItemDataList.get(i).getCarAge() + "年");
        myViewHolder.tvCarNum.setText(mItemDataList.get(i).getApplySeats() + "座");
        myViewHolder.tvStartAddress.setText(mItemDataList.get(i).getOriginCity().replace("市",""));
        myViewHolder.tvEndAddress.setText(mItemDataList.get(i).getArriveCity().replace("市",""));
        myViewHolder.tvMoney.setText("￥"+ DoubleUtil.m2(mItemDataList.get(i).getPrice()));
        myViewHolder.tvCreateData.setText("该用车请求于"+mItemDataList.get(i).getCreateTime()+"发布");
        myViewHolder.tvStartData.setText(mItemDataList.get(i).getBeginTime()+"(用车)");
        Glide.with(mContext).load(mItemDataList.get(i).getMemberAvatar()).into(myViewHolder.headImg);
    }

    @Override
    public int getListLayoutId() {
        return R.layout.main_item;
    }

    @Override
    public RecyclerView.ViewHolder createViewHolder(View view) {
        return new MyViewHolder(view);
    }

    class MyViewHolder extends BaseRecyclerViewHolder {
        @BindView(R.id.tv_travel_name)
        TextView tvTravelName;
        @BindView(R.id.tv_car_num)
        TextView tvCarNum;
        @BindView(R.id.tv_start_address)
        TextView tvStartAddress;
        @BindView(R.id.tv_start_data)
        TextView tvStartData;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        @BindView(R.id.tv_end_address)
        TextView tvEndAddress;
        @BindView(R.id.tv_create_data)
        TextView tvCreateData;
        @BindView(R.id.head_img)
        ImageView headImg;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
